<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件

function curl($url,$data=null)
{
	// 1初始化
	$ch=curl_init();
	// 2设置参数
	// 请求的地址
	curl_setopt($ch, CURLOPT_URL, $url);
	// curl_setopt($ch, CURLOPT_HEADER, false);
	// 以文件流形式返回，不直接输出
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	// https请求
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查  
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
	if($data){
		//post请求
		curl_setopt($ch, CURLOPT_POST, true);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
	}
	// 3发送请求
	$result=curl_exec($ch);
	// 4释放资源
	curl_close($ch);
	// return $result;
	$tmpArr=json_decode($result,true);
	if(is_array($tmpArr)){
		return $tmpArr;
	}else{
		return $result;
	}
}


function p($arr){
	if(is_array($arr)){
		echo '<pre>';
		print_r($arr);
		echo '</pre>';
		

	}else{
		echo $arr."<br/>";
	}

}